<!--
 * @Description: 健康登记--表单填写页
 * @Autor: -
 * @Date: 2021-07-11 13:28:19
 * @LastEditors: luojie
 * @LastEditTime: 2021-08-01 23:41:26
-->

<template>
<view class="investigate-content myform">
  <uni-forms :value="formData" ref="form" validate-trigger="bind" err-show-type="undertext">
    <!-- 顶部个人信息 -->
    <view class="investigate-info">
      <view v-for="item in investigateInfo" :key="item.name">
        <view>{{ item.name }}</view>
        <view>{{ item.value || '' }}</view>
      </view>
    </view>

    <!-- 基本信息 -->
    <view class="form-cont">
      <view class="max-title" @click="changeDisplay">基本信息<img :class="!basicShow ? 'rotate' : ''" src="https://szgd-dev.tgovcloud.com/public/images/arr-down.png" /></view>
      <view class="basic-info" v-show="basicShow">
        <view v-for="item in investigateInfo1" :key="item.name">
          <view>{{ item.name }}</view>
          <view v-if="item.name == '性别'">{{
              item.value == 0 ? "女" : item.value == 1 ? "男" : ''
            }}</view>
          <view v-else>{{ item.value == null ? "" : item.value }}</view>
        </view>
      </view>

      <!-- 既往病史 -->
      <view class="max-title">
        既往病史
        <view class="check-no" @click="checkNo(0)">健康无异常</view>
        <!-- <view class="check-yes" @click="checkNo(1)">全选是</view> -->
      </view>
      <view class="medical-history">
        <view class="sub-title">基础性疾病</view>
        <view v-for="(item, index) in jiBingData" class="flex-box" :key="item.fieId">
          <view>{{ index + 1 }}.{{ item.name }}
            <view v-if="item.required" class="required">*</view>
          </view>
          <view>
            <uni-data-checkbox v-model="item.value" :localdata="item.range" class="my-raido"></uni-data-checkbox>
          </view>

          <view v-if="item.type == 'checkBox' && item.value == 1">
            <uni-data-checkbox multiple v-model="item.checkBoxValue" :localdata="item.array"></uni-data-checkbox>
          </view>

          <view v-if="item.type == 'checkBoxOther' && item.value == 1">
            <uni-data-checkbox multiple v-model="item.checkBoxValue" :localdata="item.array" @change="checkBoxOtherChange($event, item)"></uni-data-checkbox>
            <uni-forms-item name="name" :label="item.inputLabel" v-if="item.isShowInput">
              <uni-easyinput type="text" v-model="item.inputValue" placeholder="请输入"></uni-easyinput>
            </uni-forms-item>
          </view>

          <view v-if="item.type == 'input' && item.value == 1" class="my-input-style">
            <uni-forms-item name="name" :label="item.inputLabel">
              <uni-easyinput type="text" v-model="item.inputValue" placeholder="请输入"></uni-easyinput>
            </uni-forms-item>
          </view>

          <view class="picker-control" v-if="item.hasTime && item.value == 1">
            <view>{{ item.timeLabel }}</view>
            <picker @change="bindPickerChange($event, item)" mode="date" :value="item.timeValue" class="picker-control-con-picker">
              <view class="uni-input picker-content-text">
                {{ item.timeValue }}
                <view class="picker-content-img"></view>
              </view>
            </picker>
          </view>

          <view class="picker-control" v-if="item.type == 'selectOther' && item.value == 1">
            <picker mode="selector" :range="item.options" range-key="label" :value="item.selectValue" class="picker-control-con-picker" @change="jiZhengChange($event, item)">
              <view class="uni-input picker-content-text">
                {{
                    item.selectValue == null
                      ? item.selectLabel
                      : item.options[item.selectValue].label
                  }}
                <view class="picker-content-img"></view>
              </view>
            </picker>
            <!-- 选了其他，显示输入框 -->
            <view v-if="item.selectValue == item.otherValue">
              <uni-forms-item name="name" :label="item.inputLabel">
                <uni-easyinput type="text" v-model="item.inputValue" placeholder="请输入"></uni-easyinput>
              </uni-forms-item>
            </view>
          </view>
        </view>
      </view>

      <!-- 急症病史 -->
      <view class="medical-history">
        <view class="jizheng-form">
          <view class="sub-title">急症病史<view class="required">*</view>
          </view>
          <view>
            <uni-data-checkbox v-model="jiZhengData.value" :localdata="jiZhengData.range" class="my-raido"></uni-data-checkbox>
          </view>
        </view>
        <view v-if="jiZhengData.value == 1">
          <!-- 选是，显示picker -->
          <!-- <view class="picker-control">
              <picker
                mode="selector"
                :range="jiZhengData.options"
                range-key="label"
                :value="jiZhengData.selectValue"
                class="picker-control-con-picker"
                @change="jiZhengChange($event, jiZhengData)"
              >
                <view class="uni-input picker-content-text">
                  {{
                    jiZhengData.selectValue == null
                      ? "请选择急症病史"
                      : jiZhengData.options[jiZhengData.selectValue].label
                  }}
                  <view class="picker-content-img"></view>
                </view>
              </picker>
            </view> -->
          <!-- 由于picker只能获取到选的第几项，value值是index。所以值需要处理一下 -->
          <!-- 选了其他，显示输入框 -->
          <!-- <view v-if="jiZhengData.selectValue == jiZhengData.otherValue - 1">
              <uni-forms-item name="name" :label="jiZhengData.inputLabel">
                <uni-easyinput
                  type="text"
                  v-model="jiZhengData.inputValue"
                  :placeholder="jiZhengData.inputLabel"
                ></uni-easyinput>
              </uni-forms-item>
            </view>
          </view> -->
          <uni-data-checkbox multiple v-model="jiZhengData.checkBoxValue" :localdata="jiZhengData.array" @change="checkBoxOtherChange($event, jiZhengData)"></uni-data-checkbox>

          <uni-forms-item name="name" :label="jiZhengData.inputLabel" v-if="jiZhengData.isShowInput">
            <uni-easyinput type="text" v-model="jiZhengData.inputValue" placeholder="请输入"></uni-easyinput>
          </uni-forms-item>
        </view>
      </view>

      <!-- 服药史 -->
      <view class="medical-history">
        <view class="sub-title">服药史</view>
        <view v-for="(item, index) in medicationHistory" class="flex-box" :key="item.fieId">
          <view>{{ index + 1 }}.{{ item.name }}
            <view v-if="item.required" class="required">*</view>
          </view>
          <view>
            <uni-data-checkbox v-model="item.value" :localdata="item.range" class="my-raido"></uni-data-checkbox>
          </view>
          <view v-if="item.type == 'input' && item.value == 1" class="my-input-style">
            <uni-forms-item name="name" :label="item.inputLabel">
              <uni-easyinput type="text" v-model="item.inputValue" placeholder="请输入"></uni-easyinput>
            </uni-forms-item>
          </view>
        </view>
      </view>

      <!-- 流行病学史 -->
      <view class="medical-history epidemiology-his">
        <view class="sub-title">流行病学史
        </view>
        <view>
          <uni-forms-item name="name" :label="epidemiologyHis.inputLabel">
            <uni-easyinput type="text" v-model="epidemiologyHis.inputValue" placeholder="请输入"></uni-easyinput>
          </uni-forms-item>
        </view>
      </view>

      <!-- 疫苗接种史 -->
      <view class="medical-history vaccination-wrapper">
        <view v-for="(item, index) in vaccination" :key="index">
          <view class="flex-box">
            <view class="sub-title">{{ item.name }}
              <view v-if="item.required" class="required">*</view>
            </view>
            <view>
              <uni-data-checkbox v-model="item.value" :localdata="item.range" class="my-raido"></uni-data-checkbox>
            </view>
          </view>
          <view v-if="item.value == 1" class="vaccination-content">
            <view v-for="value in item.array" :key="value.fieId">
              <view class="vaccination-title">{{ value.name }}</view>
              <view v-if="value.type == 'time'" class="picker-control">
                <picker mode="date" @change="vaccinesPickerChange($event, value)" :value="value.value" class="picker-control-con-picker">
                  <view class="uni-input picker-content-text">
                    {{
                      value.value == "" || value.value == null || value.value == undefined
                        ? "请选择时间"
                        : value.value
                    }}
                    <view class="picker-content-img"></view>
                  </view>
                </picker>
              </view>
              <view v-if="value.type == 'select'" class="picker-control">
                <picker mode="selector" :range="vaccineCompanys" range-key="label" @change="vaccinesSelectChange($event, value)" :value="value.valueIndex" class="picker-control-con-picker">
                  <view class="uni-input picker-content-text">
                    {{
                      value.value == null || value.value == undefined || value.value == ''
                        ? "请选择厂家"
                        : vaccineCompanysObj[value.value]
                    }}
                    <view class="picker-content-img"></view>
                  </view>
                </picker>
              </view>
            </view>
          </view>
        </view>
      </view>

      <!-- 其他史 -->
      <view class="medical-history">
        <view class="sub-title">其他史</view>
        <view v-for="(item, index) in otherHistory" class="flex-box" :key="item.fieId">
          <view>{{ index + 1 }}.{{ item.name }}
            <view v-if="item.required" class="required">*</view>
          </view>
          <view>
            <uni-data-checkbox v-model="item.value" :localdata="item.range" class="my-raido"></uni-data-checkbox>
          </view>
          <view v-if="item.type == 'input' && item.value == 1" class="my-input-style">
            <uni-forms-item name="name" :label="item.inputLabel">
              <uni-easyinput type="text" v-model="item.inputValue" placeholder="请输入"></uni-easyinput>
            </uni-forms-item>
          </view>
          <view class="picker-control" v-if="item.hasTime && item.value == 1">
            <picker @change="bindPickerChange($event, item)" mode="date" :value="item.timeValue" class="picker-control-con-picker">
              <view class="uni-input picker-content-text">
                {{ item.timeValue }}
                <view class="picker-content-img"></view>
              </view>
            </picker>
          </view>
        </view>
      </view>

      <!-- 心情 -->
      <view class="medical-history mood-form">
        <view class="flex-box" v-for="item in currentStatus" :key="item.fieId">
          <view class="vaccination-title">{{ item.name }}</view>
          <view class="picker-control">
            <picker mode="selector" :range="item.options" range-key="label" @change="vaccinesSelectChange($event, item)" :value="item.valueIndex" class="picker-control-con-picker">
              <view class="uni-input picker-content-text">
                {{
                    item.value == null
                      ? item.selectLabel
                      : item.options[item.valueIndex].label
                  }}
                <view class="picker-content-img"></view>
              </view>
            </picker>
          </view>
        </view>
      </view>

      <!-- 筛查登记 -->
      <view class="medical-history vaccination-wrapper">
        <view class="sub-title">筛查登记</view>
        <view v-for="(item, index) in screenRegis[0].array" :key="index">
          <view class="flex-box" v-if="item.type == 'select'">
            <view class="vaccination-title">{{ item.name }}</view>
            <view class="picker-control">
              <picker mode="selector" :range="item.options" range-key="label" @change="vaccinesSelectChange($event, item)" :value="item.valueIndex" class="picker-control-con-picker">
                <view class="uni-input picker-content-text">
                  {{
                    item.value == null
                      ? "请选择筛查结果"
                      : item.options[item.valueIndex].label
                  }}
                  <view class="picker-content-img"></view>
                </view>
              </picker>
            </view>
          </view>
          <uni-forms-item v-if="item.type == 'input'" name="name" :label="item.name" required>
            <uni-easyinput type="text" v-model="item.value" placeholder="请输入"></uni-easyinput>
          </uni-forms-item>
        </view>
      </view>

      <!-- 紧急联系人 -->
      <view class="medical-history">
        <view class="sub-title">紧急联系人</view>
        <uni-group class="investigate-group">
          <uni-forms-item v-for="item in otherQuestions" :key="item.name" name="name" :label="item.name">
            <uni-easyinput type="text" v-model="item.value" placeholder="请输入"></uni-easyinput>
          </uni-forms-item>
        </uni-group>
      </view>

      <button class="btn" @click="submitAll">
        <text style="color: #fff">提交</text>
      </button>
    </view>
  </uni-forms>
  <!-- 是否导入预登记 -->
  <uni-popup ref="popup" type="center" :mask-click="false" class="my-popup">
    <view class="my-popup-box">
      <view class="my-popup-title">该客人已进行预填报，是否导入排查登记表中？</view>
      <view class="my-popup-content text-warn">
        <icon class="icon" type="info" color="#DF6434" size="16"></icon>
        <text class="text">您需要对此信息逐一询问核实和确认</text>
      </view>
      <view class="my-popup-handler">
        <view class="my-popup-handler__item" @click="popupConfirm(0)">取消</view>
        <view class="my-popup-handler__item confirm" @click="popupConfirm(1)">确定</view>
      </view>
    </view>
  </uni-popup>
</view>
</template>

<script>
import {
  getData,
  getPersonHealth
} from "../../api/index";
import { cardTypes, vaccineCompanys } from "@/data";
import {
  investigateCong as formCong
} from "./formConfig";
import dayjs from 'dayjs';

function cpyFunc(obj){
  try {
  return JSON.parse(JSON.stringify(obj));
  } catch (error) {}
};
export default {
  data() {
    return {
      isChange: '0',
      vaccineCompanys,
      name: "",
      identityType: "",
      nation: "",
      age: "",
      phone: "",
      isolationPoint: "",
      sex: "0",
      id: "",
      formData: {
        otherDiseases: "",
      },
      // 个人信息
      investigateInfo: cpyFunc(formCong.investigateInfo),
      // 基本信息
      investigateInfo1: cpyFunc(formCong.baseInfo),
      // 既往病史
      jiBingData: cpyFunc(formCong.jiBingData),
      // 急症病史
      jiZhengData: cpyFunc(formCong.jiZhengData),
      // 服药史
      medicationHistory: cpyFunc(formCong.medicationHistory),
      // 流行病学史
      epidemiologyHis: cpyFunc(formCong.epidemiologyHis),
      // 疫苗
      vaccination: cpyFunc([...formCong.vaccination1,...formCong.vaccination2,...formCong.vaccination3]),
      // 其他史
      otherHistory: cpyFunc(formCong.otherHistory),
      // 心情状态
      currentStatus: cpyFunc(formCong.currentStatus),
      // 紧急联系人
      otherQuestions: cpyFunc(formCong.otherQuestions),
      // 筛选排查
      screenRegis: cpyFunc(formCong.screenRegis),
      text: "",
      basicShow: false,
      thisTime: "",
    };
  },
  computed: {
    vaccineCompanysObj() {
      let obj = {};
      this.vaccineCompanys.forEach(t => {
        obj[t.value] = t.label;
      })
      return obj;
    }
  },
  onLoad(e) {
    // this.vaccination = [...formCong.vaccination1,...formCong.vaccination2,...formCong.vaccination3]
    this.isChange = e.isChange;
    this.isPreData = e.isPreData; // 是否导致预登记信息
    this.vaccination.forEach(ele=>ele.value=null);
    this.thisTime = dayjs().format('YYYY-MM-DD') + " 00:00:00";
    // this.$set(this.vaccination[0], 'value')
    // this.vaccination[0].array.forEach(item=>{
    //   if(item.type=='time'){
    //     item.value = thisTime;
    //   }
    // })
    // this.jiBingData[10].timeValue = this.thisTime;
    // this.vaccination[0].data.forEach(item=>{
    //   if(item.type=='time'){
    //     item.value = this.thisTime;
    //   }
    // })
    this.getDataInfo();
  },
  methods: {
    async initData() {
      // this.jiBingData[10].timeValue = this.thisTime;
      let {
        name,
        telPhone,
        gender: sex,
        nationality,
        nation,
        hotelContact: isolationPersonInCharge,
        inPostRoomNum,
        moveStartTime,
        personClassify,
        inPostTime,
        age,
        cardId,
        cardType,
        hotelAddr,
        hotelName,
        houseId,
        moveEndTime,
      } = uni.getStorageSync("personInfo");
      let { phone } = uni.getStorageSync('isolationPersonnel')
      let params = {
        cardId,
        cardType,
        hotelAddr,
        hotelName,
        houseId,
        moveStartTime,
        moveEndTime,
        personClassify,
        name,
        phone,
        sex,
        nationality,
        nation,
        age,
        inPostRoomNum,
        isolationPersonInCharge,
        inPostTime,
        phone: telPhone || phone
      };
      let investigateInfo = this.investigateInfo;
      investigateInfo.map((item) => {
        if (item.fieId == "sex") {
          item.value = this.gender(params[item.fieId],params)
          // item.value = params[item.fieId] !== null ? (params[item.fieId] == 1 ? "男" : params[item.fieId]==0?"女":'') : "";
        } else {
          item.value = params[item.fieId];
        }
      });
      this.investigateInfo = investigateInfo;

      let personTypeList = await this.$store.dispatch('getDic','person_classify');
      this.investigateInfo1.forEach((item) => {
        // 人员类型
        if (item.fieId == "personClassify") {
          let arr = personTypeList.filter(obj => {
            return obj.value == params[item.fieId];
          })
          item.value = arr[0] && arr[0].label;
        } else if(item.fieId == 'inPostRoomNum' && params[item.fieId]){
          item.value = params[item.fieId];
        }else if(item.fieId != 'inPostRoomNum'){
          item.value = params[item.fieId];
        }
      });
    },
    gender:function(sex,params){
      // 先判断gender，若没有值则判断身份证倒数第二位，奇数为男，偶数为女
      if (sex == 0) {
        return '女'
      }else if(sex == 1){
        return '男'
      }else{
        if (params.cardType == 0) {
          console.log('身份证倒数第二位：',params.cardId.slice(-2,-1));
          if (params.cardId && params.cardId.slice(-2,-1)%2 == 0 ) {
            return '女'
          }else if(params.cardId && params.cardId.slice(-2,-1)%2 != 0){
            return '男'
          }else{
            return ''
          }
        }else{
          return ''
        }
      }
    },
    async getDataInfo() {
      let {
        personId,
        telPhone,
        cardId
      } = uni.getStorageSync("personInfo");
      console.log(uni.getStorageSync("personInfo"))
      let params = { personId };
      // 健康排查查询并且赋值
      getData("healthCheck", "get", params).then((data) => {
        console.log('currentStatus', JSON.parse(JSON.stringify(this.currentStatus)))
        this.initData();
        if (data.name) {
          this.dataFormater(data);
        }
        if(data && (data.isHypertension == null || data.isHypertension == undefined)){
          this.getPreHealth({ cardId })
        }
      });
      // if (this.isPreData) {
      //   // 获取公众预登记信息
      //   this.getPreHealth({ cardId })
      // }
    },
    // 查询预登记健康信息
    getPreHealth(params) {
      const _this = this;
      return getPersonHealth(params).then(data => {
        if (data) {
          let arr = Object.keys(data);
          arr = arr.filter(t => data[t]);
          if (arr.length) {
            this.preHealthData = data;
            this.$refs.popup.open();
            // uni.showModal({
            //   title: '该客人已进行预填报，是否导入排查登记表中？',
            //   content: '您需要对此信息逐一询问核实和确认',
            //   confirmColor: '#2C9AF1',
            //   success(e) {
            //     if (e.confirm) {
            //       _this.dataFormater(data);
            //     }
            //   }
            // });
          }
        }
      });
    },
    popupConfirm(value) {
      if (value) {
        this.dataFormater(this.preHealthData);
      }
      this.$refs.popup.close();
    },
    // 健康数据格式化
    dataFormater(data) {
      let arr = [
        // this.investigateInfo,
        this.jiBingData,
        [this.jiZhengData],
        this.medicationHistory,
        [this.epidemiologyHis],
        [...this.vaccination],
        this.otherHistory,
        this.currentStatus,
        this.screenRegis,
        this.otherQuestions,
      ];
      this.investigateInfo1.forEach(item=>{
        if(item.fieId == 'inPostRoomNum'){
            item.value = data[item.fieId]
          }
      })
      arr.forEach((row) => {
        row.forEach((item) => {
          var val = Number(data[item.fieId]);
          if (!isNaN(val)) {
            if (data[item.fieId] == null) {
              item.value = data[item.fieId] || item.value;
            } else {
              item.value = Number(data[item.fieId]);
            }
            if (item.inputFieId) {
              item.inputValue = data[item.inputFieId];
            }
            // 证件类型
            if (item.fieId == "cardType") {
              cardTypes.forEach((obj) => {
                if (obj.value == data[item.fieId]) {
                  item.value = obj.label;
                }
              });
            }
          } else {
            item.value = data[item.fieId];
          }
          // 疫苗接种相关
          if (item.fieId == "ymzsdyzsf" || item.fieId == "ymzsdezsf" || item.fieId == "ymzsdszsf") {
            // item.value = data[item.fieId] ? Number(data[item.fieId]) : 0;
            item.array.map((obj, index) => {
              obj.value = data[obj.fieId];
              if (index == 1) {
                obj.options.forEach((t,i) => {
                  if (obj.value == t.value) {
                    obj.valueIndex = i;
                  }
                })
              }
            });
          }

          // 心情状况
          if (item.fieId == "feelingCondition" || item.fieId == "sleepCondition") {
            // console.log(item)
            item.value = data[item.fieId] || item.value;
            item.options.forEach((t,i) => {
              if (item.value == t.value) {
                this.$set(item, 'valueIndex', i);
                // console.log(item, item.valueIndex)
              }
            })
          }

          // 筛选排查
          if (item.fieId == "screenRegis") {
            item.array.map((obj) => {
              obj.value = data[obj.fieId] || obj.value;
              obj.options.forEach((t,i) => {
                if (obj.value == t.value) {
                  obj.valueIndex = i;
                }
              })
            });
          }

          // 慢性呼吸系统疾病
          if (item.fieId == "isChronic") {
            let checkBoxValue = [
              data.isPulmonaryTuberculosis,
              data.isCopd,
              data.isEmphysema,
              data.isAsthma,
            ];
            let value = 0;
            item.checkBoxValue = [];
            if (data[item.fieId] == '1') {
              checkBoxValue.forEach((obj, idx) => {
                if (obj == 1) {
                  item.checkBoxValue.push(idx);
                  value = 1;
                }
              });
              if (data[item.inputFieId]) {
                item.checkBoxValue.push(item.otherValue);
                value = 1;
              }
              item.inputValue = data[item.inputFieId];
            }
            item.value = value;
            console.log(item.checkBoxValue)
            item.isShowInput = item.checkBoxValue.length > 0 && item.checkBoxValue.indexOf(item.otherValue) != -1 ? true : false;
          }

          // 其他需要关注疾病或情况
          if (item.inputFieId == 'otherCondition') {
            if (data[item.inputFieId]) {
              item.value = 1;
              item.inputValue = data[item.inputFieId]
            } else {
              item.value = 0;
            }
          }

          // 急症病史
          if (item.fieId == "jzbs") {
            // 是否
            item.value = data[item.fieId] && data[item.fieId] != '0' ? 1 : 0;
            // 复选框的值
            item.checkBoxValue = data[item.fieId] ?
              data[item.fieId].split(",") :
              [];
            // 其他项填写的值
            item.inputValue = data[item.inputFieId] || "";
            item.isShowInput = data[item.fieId] && data[item.fieId].indexOf(item.otherValue) != -1 ? true : false;
          }

          // 有时间的话，比如：疟疾等重点传染疾病同史
          if (item.hasTime) {
            item.timeValue = data[item.timeFieId];
          }
        });
      });
    },
    bindPickerChange(e, item, type) {
      if (type == "value") {
        item[type] = e.detail.value + " 00:00:00";
        return;
      }
      item.timeValue = e.detail.value + " 00:00:00";
    },
    vaccinesChange(e, item) {},
    jiZhengChange(e, item) {
      item.selectValue = e.detail.value;
    },
    vaccinesPickerChange(e, item) {
      item.value = e.detail.value;
    },
    vaccinesSelectChange(e, item) {
      let index = e.detail.value;
      item.valueIndex = index;
      item.value = item.options[index] ? item.options[index].value : e.detail.value;
    },
    checkNo(value) {
      this.jiBingData.forEach((item) => {
        item.value = value;
      });
      this.jiZhengData.value = value;
      this.medicationHistory.forEach((item) => {
        item.value = value;
      });
      this.vaccination.forEach((item) => {
        this.$set(item, 'value', value);
      });
      this.otherHistory.forEach((item) => {
        item.value = value;
      });
      this.currentStatus.forEach(item => {
        item.value = '0'
      })
      this.screenRegis[0].array.forEach(item => {
        item.value = '0'
      })
    },
    checkBoxOtherChange(e, item) {
      item.isShowInput =
        item.checkBoxValue.indexOf(item.otherValue) === -1 ? false : true;
    },
    changeDisplay() {
      this.basicShow = !this.basicShow;
    },
    onSelectChange(e, item) {
      item.inputValue = e.detail.value;
      this.vaccination = [...this.vaccination];
    },
    submitAll() {
      let name = "";
      let tipText = "";
      // 校验单选框
      this.jiBingData.forEach((item) => {
        let isCheckbox = item.type == 'checkBox' || item.type == 'checkBoxOther' ? true : false;
        // 如果是必填项，值不能为空，或者选了是，用户输入的值不能为空
        if (item.required && !name && item.value == null) {
          name = item.name;
          tipText = "未选择";
          return;
        } else if (
          item.required &&
          !name &&
          item.value == 1 &&
          ((isCheckbox && item.checkBoxValue.length === 0) ||
            (item.type == "input" && !item.inputValue))
        ) {
          name = item.name;
          tipText = "未填写";
          return;
        }
        // input类型处理
        if (item.type == 'input' && item.value == '0') {
          item.inputValue = ''
        }
      });
      // 急症校验
      let jzdata = this.jiZhengData;
      if (!name && jzdata.value == null) {
        name = '急症病史';
        tipText = "未选择";
      } else if (
        !name &&
        jzdata.value == 1 &&
        jzdata.checkBoxValue.length === 0
      ) {
        name = '急症病史';
        tipText = "未填写";
      }
      this.vaccination.forEach((item) => {
          if (item.required && item.value == null) {
            name = item.name;
            tipText = "未选择";
            return;
          }
      });
      this.screenRegis[0].array.forEach((item) => {
        if (item.required && item.value == null) {
          name = item.name;
          tipText = "未选择";
          return;
        }
      });
      if (name) {
        uni.showToast({
          title: tipText + name,
          duration: 3000,
          icon: "none",
        });
        return;
      }
      // this.vaccination.map(item=>item)
      // console.log(this.vaccination)
      var params = [
        [...this.investigateInfo, ...this.investigateInfo1],
        [
          ...this.jiBingData,
          this.jiZhengData,
          ...this.medicationHistory,
          this.epidemiologyHis,
          ...this.vaccination,
          ...this.otherHistory,
          ...this.currentStatus,
          ...this.screenRegis,
          ...this.otherQuestions,
        ],
      ];
      uni.setStorage({
        key: "healthScreenData",
        data: params,
      });
      uni.navigateTo({
        url: `./investigateDetails?isChange=${this.isChange}`,
      });
    },
  },
};
</script>

<style lang="scss">


.investigate-content {
  display: flex;
  flex-direction: column;

  .jizheng-form {
    display: flex;
    justify-content: space-between;
  }

  .form-cont {
    background: #fff;
  }

  .title {
    font-size: 40rpx;
    color: #000000;
    font-weight: bold;
  }

  .sub-title {
    font-size: 26rpx;
    line-height: 80rpx;
    font-weight: bold;
  }

  .max-title {
    font-size: 40rpx;
    color: #000000;
    font-weight: 600;
    height: 98rpx;
    line-height: 98rpx;
    background: #fff;
    border-bottom: 1rpx solid #e5e5e5;
    padding: 0 32rpx;
    position: relative;
    display: flex;
    justify-content: space-between;

    &~.basic-info {
      margin-top: 0;
    }

    img {
      width: 26rpx;
      height: 15rpx;
      position: absolute;
      right: 38rpx;
      top: 50%;
      transform: translateY(-50%);
      transition: all 0.5s;

      &.rotate {
        transform: rotate(-90deg);
        transition: all 0.5s;
      }
    }

    .check-no,
    .check-yes {
      color: #53adf3;
      font-size: 30rpx;
      display: inline-block;
    }

    .check-no {
      margin-right: 76rpx;
    }

    .check-yes {
      margin-left: 50rpx;
    }
  }

  .investigate-info {
    font-size: 30rpx;
    background: #fff;
    padding: 0 32rpx;
    margin: 30rpx 0;
  }

  .investigate-info>view {
    display: flex;
    justify-content: space-between;
    font-weight: 500;
    padding:18rpx 0;
    border-bottom: 1rpx solid #e5e5e5;
  }

  .investigate-info view view:first-child {
    color: #999999;
  }

  .investigate-info view view:last-child {
    color: #000000;
    font-size: 32rpx;
  }

  .basic-info {
    font-size: 30rpx;
    background: #fff;
    padding: 0 32rpx 30rpx;
    margin: 30rpx 0;
    overflow: hidden;

    &>view {
      &>view:first-child {
        color: #333333;
        font-size: 26rpx;
        margin-top: 18rpx;
        font-weight: bold;
      }

      &>view:last-child {
        color: #666666;
        font-size: 24rpx;
        border-bottom: 1rpx solid #e4e4e4;
        min-height: 60rpx;
        line-height: 60rpx;
      }
    }
  }

  .medical-history {
    background: #fff;
    padding: 0 32rpx;

    .uni-data-checklist {
      margin: 20rpx 0;
    }

    .required {
      display: inline-block;
      color: red;
      margin-left: 10rpx;
    }
  }

  .lettle-title {
    font-size: 40rpx;
    font-weight: 600;
    line-height: 98rpx;
    height: 98rpx;
  }

  .input-style {
    font-size: 24rpx;
    margin-top: 20px;
    border-bottom: 1rpx solid #e4e4e4;
  }

  .flex-box {
    font-size: 26rpx;
    display: flex;
    justify-content: space-between;
    color: #333333;
    flex-wrap: wrap;

    &>view {
      line-height: 100rpx;
    }

    text {
      font-size: 26rpx;
    }

    .my-input-style {
      height: auto;
      width: 100%;

      .content-clear-icon {
        height: 22rpx;
        line-height: 22rpx;
      }
    }
  }

  .picker-control {
    width: 100%;
    box-sizing: border-box;
    align-items: center;
    color: #333333;
    margin-bottom: 10rpx;

    &-title {
      font-weight: 500;
      font-size: 26rpx;

      &-picker {
        margin-top: 20rpx;
        padding: 20rpx 20rpx;
        text-align: center;
        border: 1px solid #f2f2f2;
        border-radius: 8rpx;

        &-date {
          border-left: 0;
          border-right: 0;
          border-top: 0;
          border-bottom: 1px solid #f2f2f2;

          .uni-input {
            line-height: 80rpx;
          }
        }

        .uni-input {
          width: 100%;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          font-size: 26rpx;
        }
      }
    }

    .picker-content-text {
      box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.16);
      border-radius: 6px;
      position: relative;
      padding-left: 40rpx;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
      padding-right: 48rpx;
      .picker-content-img {
        width: 26rpx;
        height: 15rpx;
        background: url("https://szgd-dev.tgovcloud.com/public/images/arr-down.png") no-repeat;
        background-size: 100% 100%;
        position: absolute;
        right: 30rpx;
        top: 50%;
        transform: translateY(-50%);
      }
    }
  }

  .btn {
    width: 686rpx;
    height: 94rpx;
    background: #2c9af1;
    border-radius: 16rpx;
  }

  .small-title {
    font-size: 30rpx;
    font-family: PingFang SC;
    font-weight: bold;
    color: #000000;
    padding: 40rpx 0 0 0;
  }

  .investigate-group {
    .uni-group {
      margin-top: 0 !important;
    }

    .uni-group__content {
      padding: 0;
    }
  }

  .vaccination-wrapper {
    .label {
      font-size: 30rpx;
      font-weight: bold;
      color: #000000;
      padding: 40rpx 0 0 0;
      margin-bottom: 20rpx;
    }

    .flex-box {
      width: 100%;
    }

    .vaccination-content {
      width: 100%;

      &>view {
        margin-bottom: 30rpx;
      }

      .vaccination-title {
        height: 60rpx;
      }
    }

    .vaccination-select {
      border-bottom: 1px solid #e5e5e5;
    }
  }

  .picker-content-text {
    height: 90rpx;
    line-height: 90rpx;
  }

  .epidemiology-his {
    /deep/ .uni-forms-item__inner {
      margin: 0;
    }

    padding-bottom: 20rpx;
  }

  .mood-form {
    padding-bottom: 20rpx;

    /deep/ .uni-forms-item__inner:last-child {
      margin: 0;
    }
  }
  .my-popup-box {
    background-color: #FFF;
    border-radius: 20rpx;
    margin: 0 40rpx;
    max-width: 600rpx;
    .my-popup-title {
      color: #000;
      padding: 40rpx 30rpx 20rpx;
      font-weight: bold;
      font-size: 34rpx;
    }
    .my-popup-content {
      color: #666;
      padding: 20rpx 30rpx 30rpx;
      font-size: 32rpx;
      .icon {
        vertical-align: middle;
        margin-right: 16rpx;
      }
      .text {
        vertical-align: middle;
      }
    }
    .my-popup-handler {
      display: flex;
      border-top: 1px solid #F5F5F5;
      font-weight: 500;
    }
    .my-popup-handler__item {
      width: 50%;
      box-sizing: border-box;
      color: #000;
      font-size: 36rpx;
      height: 100rpx;
      line-height: 100rpx;
      text-align: center;
      &.confirm {
        border-left: 1px solid #F5F5F5;
        color: #2c9af1;
      }
    }
    .text-warn {
      color: #DF6434;
    }
  }
}
</style>
